/**
 * Created by zander on 2017/11/14.
 */
$(document).ready(function () {
    $("#submit").click(function () {
        var a = $("#inputName").val();
        var b = $("#inputPassword").val();
        $.ajax({
            type: "POST",
            url: "/login",
            data: {"username": a, "password": b},
            dataType: "json",
            success: function (ret) {
                if (ret.result == "0000") {
                    window.location.href = '/user'
                }
                else if (ret.result == "0001") {
                    alert('用户名密码错误');
                    window.location.href = '/intest'
                }
            },
            error: function () {
                alert("Error 500,请联系开发人员！");
            }
        });
    });
});

function keyLogin() {
    if (event.keyCode == 13) {
        document.getElementById("submit").click();
    }
}

